#include "app_buffer.h"

int main(int argc, char const *argv[])
{
    // 初始化缓冲区
    Buffer *buffer = app_buffer_init(1024);

    // char data[128];
    // for (int i = 0; i < 128; i++)
    // {
    //     data[i] = 'a';
    // }
    // app_buffer_write(buffer, data, 128);
    // char read_buf1[256];
    // int buf1_len = app_buffer_read(buffer, read_buf1, 256);
    // log_info("第一次读取数据 %.*s,长度为：%d", buf1_len, read_buf1, buf1_len);

    // char read_buf2[256];
    // int buf2_len = app_buffer_read(buffer, read_buf2, 256);
    // log_info("第二次读取数据 %.*s,长度为：%d", buf2_len, read_buf2, buf2_len);

    // 写入数据
    app_buffer_write(buffer, "abcd", 5);
    app_buffer_write(buffer, "efghhh", 8);

    // 读取数据
    char read_buf1[10];
    int buf1_len = app_buffer_read(buffer, read_buf1, 10);
    log_info("第一次读取数据 %.*s,长度为：%d", buf1_len, read_buf1, buf1_len);

    char read_buf2[10];
    int buf2_len = app_buffer_read(buffer, read_buf2, 10);
    log_info("第二次读取数据 %.*s", buf2_len, read_buf2);

    char read_buf3[10];
    int buf3_len = app_buffer_read(buffer, read_buf3, 10);
    log_info("第三次读取数据 %.*s", buf3_len, read_buf3);

    app_buffer_deinit(buffer);

    return 0;
}
